#----------------------------------------------------------------------
#
#  Copyright 2007, Thomas Dejanovic.
#
#  This is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as
#  published by the Free Software Foundation; either version 2.1 of
#  the License, or (at your option) any later version.
#
#  This software is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#  Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with this software; if not, write to the Free
#  Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
#  02110-1301 USA, or see the FSF site: http://www.fsf.org.
#
#----------------------------------------------------------------------
#
# this is a test hatchling to test:
#
#  - a simple register that auto increments
#
#  - a number of hardware functions to demonstrate propagation of
#    functions down the hierachy and some opperator precedence rules.
# 
#----------------------------------------------------------------------

# this wants to hatch a register block.
from hatch_node_struct import Struct
from hatch_node_register import Register
from hatch_node_mux import Mux

hatchBlock = Struct(name='timers', target='small apb slave',
                    input_ports="""tick""",
                    prefix="test_a_", header="""
/*----------------------------------------------------------------------
 *
 * Information contained herein is proprietary to and constitutes
 * valuable confidential trade secrets of <your company name here>., or
 * its licensors, and is subject to restrictions on use and disclosure.
 *
 * Copyright (c) 2007 <your company name here>.
 * All rights reserved.
 *
 * The copyright notices above do not evidence any actual or
 * intended publication of this material.
 * 
 *----------------------------------------------------------------------
 *
 * Some register map description here.
 * 
 *---------------------------------------------------------------------*/

""")

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

hatchBlock.Register('real_time_clock', width=32, sw='rw',
                    comment="""This is the real time clock and is
                    incremented at a rate of 32kHz""", auto='i',
                    auto_inc_on='tick', rollover=1, hw='r')

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

hatchBlock.RegisterBlock("sub block",
                         Pack("", 
                              Register('test_a', width=10, hw='s', default=0xa),
                              Register('test_b', width=10, hw='c', default=0xb),
                              Register('test_c', width=10, hw='i', default=0xc, sw='w'),
                              hw='d' # all the registers in this pack should get hw=d
                              ),
                         hw='w' # all the registers in this block should get hw=w
                         
                         # no sw action is specified but all these
                         # registers should be readable.
                         )

bBlock = RegisterBlock("another_sub_block",
                       Register('test_d', width=10, hw='s', default=0xd),
                       Register('test_e', width=10, hw='c', default=0xe),
                       Register('test_f', width=10, hw='i', default=0xf),
                       hw='c', # all the registers in this block should get hw=c
                       sw='rw')

hatchBlock.add_content(bBlock)

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
